package com.ruoyi.framework.web.service;

import com.ruoyi.common.utils.http.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName WechatLoginImpl
 * @Description TODO
 * @Author luguanqing
 * @Date 2021/4/14 12:01
 * @Version 1.0
 */
public class WechatLoginImpl {

    @Value("${wechat.accessTokenUrl}")
    private String pcAccessTokenUrl;

    @Value("${wechat.userInfoUrl}")
    private String pcUserInfoUrl;

    @Value("{wechat.appId}")
    private String pcAppId;

    @Value("{wechat.appSecret}")
    private String appSecret;

    private Logger logger = LoggerFactory.getLogger(getClass());

    /**
     * 获取getPcWXAccessToken(微信网站pc扫码)
     */
    private Map<String, String> getPcWXAccessToken(String code){
        logger.info("WeiXinLoginController ==> getPcWXAccessToken(){}");
        Map<String, String> resMap = new HashMap<String, String>();
        StringBuffer target = new StringBuffer();
        target.append(pcAccessTokenUrl).append("appid=").append(pcAppId).append("&secret=").append(appSecret)
                .append("&code=").append(code).append("&grant_type=authorization_code");
        logger.info("WeiXinLoginController ==> getPcWXAccessToken(){} target: " + target);
        String responceEntity = HttpClientUtil.doGet(target.toString(), "zh-cn");
//        String resMessageString = responceEntity.getMessage();
//        logger.info("WeiXinLoginController ==> getPcWXAccessToken(){} resMessageString: " + resMessageString);
//        JSONObject jSONObject = JSON.parseObject(resMessageString);
        return null;
    }
}
